package com.xsmart.oa.services.mall.mymenu;

import com.xsmart.common.constant.ResultConstant;
import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.oa.dao.mall.mymenu.RegisterDao;
import com.xsmart.oa.dao.mall.mymenu.UserLoginDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class UserDetailsService {
    @Autowired
    RegisterDao registerDao;

    public ResponseBean findByUserName(RequestBean requestBean) {
        String userName = requestBean.getRequestParamString("userName");
        Map<String, Object> user = registerDao.findByUsername(userName);
        ResponseBean responseBean = requestBean.getResponseBean();
        if (user != null) {
            responseBean.setResult(ResultConstant.SUCCESS);
            responseBean.addResultItem("userInfo", user);
        } else {
            responseBean.setResult(ResultConstant.ERROR);
        }
        return responseBean;
    }
}
